package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpReportsSMSQuarterlyReviewPageUtil extends SeleniumPageUtil {
	public final static By RSQR_LINK_CREATE = By.id("ctl44_btnSubmit");
	public final static By RSQR_SPAN_HEADER = By.id("ctl44_lblHdr");
	public final static By RSQR_TD_CRITERIA = By.xpath("//*[@id='ctl44_pnlForm']/table/tbody/tr[1]/td[4]");
	public final static By RSQR_TD_SELECT_CUSTOMER = By.xpath("//*[@id='ctl44_pnlForm']/table/tbody/tr[2]/td[1]");
	public final static By RSQR_INPUT_SELECT_CUSTOMER = By.id("ctl44_txtCustomer");
	public final static By RSQR_TD_SELECT_REGION = By.xpath("//*[@id='ctl44_pnlForm']/table/tbody/tr[3]/td[1]");
	public final static By RSQR_SELECT_REGION = By.id("ctl44_cboRegion");
	public final static By RSQR_INPUT_IMG_REGION = By.id("ctl44_imgRegion");
	public final static By RSQR_TD_SELECT_CONTRACT = By.xpath("//*[@id='ctl44_pnlForm']/table/tbody/tr[4]/td[1]");
	public final static By RSQR_INPUT_SELECT_CONTRACT = By.id("ctl44_txtContract");
	public final static By RSQR_TD_START = By.xpath("//*[@id='ctl44_pnlForm']/table/tbody/tr[5]/td[1]");
	public final static By RSQR_INPUT_START = By.id("ctl44_dteStartDate_txtDatePart");
	public final static By RSQR_IMG_START_DATE = By.id("ctl44_dteStartDate_imgDateCalendar");
	public final static By RSQR_DIV_START_DATE_CLOSE = By.id("ctl44_dteStartDate_txtDatePart_CalendarExtender_close");
	public final static By RSQR_TD_END = By.xpath("//*[@id='ctl44_pnlForm']/table/tbody/tr[6]/td[1]");
	public final static By RSQR_INPUT_END = By.id("ctl44_dteEndDate_txtDatePart");
	public final static By RSQR_IMG_END_DATE = By.id("ctl44_dteEndDate_imgDateCalendar");
	public final static By RSQR_DIV_END_DATE_CLOSE = By.id("ctl44_dteEndDate_txtDatePart_CalendarExtender_close");
	
	public final static By RSQR_CUSTOMER_LIST = By.id("ctl44_aceCustomer_completionListElem");
	public final static By RSQR_CUSTOMER_LIST_ACS = By.xpath("//*[@id='ctl44_aceCustomer_completionListElem']/li[text()='ACS']");
	
	// elements displayed after inputting customer
	public final static By RSQR_TD_CUSTOMER = By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[3]");
	
	// sign of result refreshing
	public final static By RSQR_LBL_REFRESH_MSG = By.id("ctl44_lblMsg");
	// Power Point(PPT) correct message.
	public final static By RSQR_LBL_STATUS = By.id("ctl44_lblStatus");
	// PPT Image
	public final static By RSQR_LBL_PPT_IMG = By.xpath("//*[@id='ctl44_lblStatus']/a/img");
	
	public static void enterReportsSMSQuarterlyReviewPage(){
		SpHomePageUtil.enter();
		SpHomePageUtil.enterReportsDefaultPage();
		SeleniumUtil.click(SeleniumUtil.getCachedElement(SpReportsDefaultPageUtil.RD_LINK_QUARTERLY_REVIEW));
		waitForPageToLoad();
	}
	
	public static void waitForPageToLoad() {
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.selectFrame(SpHomePageUtil.HOME_FRAME_CONTENT_NAME);
		SeleniumUtil.selectFrame(SpHomePageUtil.HOME_FRAME_REPORTS_NAME);
		SeleniumUtil.waitOnElements(new By[]{
				RSQR_LINK_CREATE, RSQR_SELECT_REGION, RSQR_INPUT_IMG_REGION, RSQR_IMG_START_DATE, RSQR_IMG_END_DATE 
			});
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(RSQR_LINK_CREATE));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(RSQR_SELECT_REGION));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(RSQR_INPUT_IMG_REGION));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(RSQR_IMG_START_DATE));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(RSQR_IMG_END_DATE));
	}
}
